<?php
	$fulname	=	$this->formText('fullname',$this->Item['fullname'],array("class"=>"text"));
	$email		=	$this->formText('email',$this->Item['email'],array("class"=>"text"));
	$title		= 	$this->formText('title',$this->Item['title'],array("class"=>"text"));
	$message	= 	$this->formTextarea('message',$this->Item['message'],array('rows'=>10));	
	$captcha 	= 	$this->captcha;
	$txtCaptcha = 	$this->formText('captcha','');
	$txtID 		= 	$this->formHidden('captchaID',$this->captcha_id);		
	$urlCaptch		 = $this->baseUrl('default/index/captcha-image');	
	$inputCaptcha	= $this->formText('captcha',null,array("class"=>"code"));
	$submit			= $this->formSubmit('submit','Gửi mail',array("class"=>"submit"));
	$linkContact	= $this->baseUrl('default/index/contact');
	
	if (count ( $this->messageError ) > 0) {
		$errors = $this->formErrors ( $this->messageError, array ('id' => 'errors' ) );
	}
?>
<div class='left'>
	<div class="content-left">
		<div class="group">
				<div class="sub-content color-blue">Liên hệ</div>
			    <div class="detail bag-white mar-0">
				    <div class="contact">
				    <?php 
				        if(empty($this->messages[0])):?>
				         <form action="<?php echo $linkContact;?>" method="post"  enctype="multipart/form-data">
				             <div class="lev">
				                 <span>Họ và tên: </span><?php echo $fulname;?>
				                 <div><?php if(!empty($this->messageError['fullname'])):echo '<p class="msg_error">'.$this->messageError['fullname'].'</p>';endif;?></div>
				             </div>
				             <div class="lev">
				                 <span>Email: </span><?php echo $email;?>
				                 <div><?php if(!empty($this->messageError['email'])):echo '<p class="msg_error">'.$this->messageError['email'].'</p>';endif;?></div>
				             </div>
				             <div class="lev">
				                 <span>Tiêu đề: </span><?php echo $title?>
				                 <div><?php if(!empty($this->messageError['title'])):echo '<p class="msg_error">'.$this->messageError['title'].'</p>';endif;?></div>
				             </div>
				             <div class="lev">
				                 <span>Nội dung: </span><?php echo $message;?>
				                 <div><?php if(!empty($this->messageError['message'])):echo '<p class="msg_error">'.$this->messageError['message'].'</p>';endif;?></div>
				             </div>
				             <div class="lev">
				                  <span>Mã xác nhận: </span>
				                  <div>
				                  	<?php echo $inputCaptcha;?>                            	
				                  	<?php if(!empty($this->messageError['captcha'])):echo '<p class="msg_error">'.$this->messageError['captcha'].'</p>';endif;?>
				                  </div>	
				             </div>
				             <div class="lev">
				             	<div>
									<div class="border-img"><?php echo $txtID . $captcha;?></div>
					             	<span id="refresh" class="refresh"></span>
				             	  </div>
				             </div>
				             <div class="lev">
				             	<div><?php echo $submit;?></div>
				             </div>
				          </form>
				      <?php else:
				           echo '<div class="notice">'.$this->messages[0].'</div>';
				      endif;?>
				      </div>
				</div>
		</div>
	</div>
</div>

<script>
	function getData(data){
		$('.border-img').html(data);
		return false;
	}
	
	function refreshCaptcha(){
		var captchaID = $("#captchaID").val();
		$.get('<?php echo $urlCaptch . '/captchaID/';?>'+captchaID,getData);
	}
	$(document).ready(function(){
		$('#refresh').click(function(e){
			e.preventDefault();
			refreshCaptcha();
		});
	});
</script>